import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', () => {
  // state
  const name = ref('tom')
  const age = ref(18)

  // getters
  const info = computed(() => {
    return `${name.value} is ${age.value} years old`
  })

  // actions
  const grow = () => {
    age.value++
  }

  const changeName = (newName) => {
    name.value = newName
  }
 

  return { name, age, info, grow, changeName }
})
